import { createRouter, createWebHashHistory } from 'vue-router'
const Layout = () => import('@/views/Layout')
const Home = () => import('@/views/Home')
const Detail = () => import('@/views/Goods')
const Login = () => import('@/views/Login')
const Cart = () => import('@/views/Cart')
const Settlement = () => import('@/views/Member/settlement')
const Order = () => import('@/views/Member/order')
// 支付
const Pay = () => import('@/views/Member/pay')
const PayResult = () => import('@/views/Member/pay/result')
const routes = [
  {
    path: '/',
    component: Layout,
    children: [{
      path: '/',
      component: Home
    },
    {
      // 一级分类详情页面
      path: '/good/:id',
      component: Detail
    },
    {
      path: '/cart',
      component: Cart
    },
    {
      path: '/settlement',
      component: Settlement
    },
    {
      path: '/order',
      component: Order
    },
    {
      path: '/pay',
      component: Pay
    },
    { path: '/pay/callback', component: PayResult }
    ]
  },
  {
    path: '/login',
    component: Login
  }

]

const router = createRouter({
  history: createWebHashHistory(),
  // 每次路由跳转重置滚动条位置
  scrollBehavior () {
    // vue2: {x:0,y:0} | vue3: { left: 0, top: 0 }
    return { left: 0, top: 0 }
  },
  routes
})

export default router
